Re: [GENERAL] Another one! :) How to convert char(1) to boolean without re-exporting tables.
В списке pgsql-general по дате отправления:
| От | Herouth Maoz |
|---|---|
| Тема | Re: [GENERAL] Another one! :) How to convert char(1) to boolean without re-exporting tables. |
| Дата | |
| Msg-id | l03110700b2ca56ffa369@[147.233.159.109] обсуждение исходный текст |
| Ответ на | Another one! :) How to convert char(1) to boolean without re-exporting tables. (Valerio Santinelli <tanis@mediacom.it>) |
| Список | pgsql-general |
At 16:58 +0200 on 19/1/99, Valerio Santinelli wrote: > char(1) won't let me insert into it the values contained in the old > table seeing they're not of the same type. Why not? It all depends on how you populate the new table. You do that usually with a SELECT statement. A select statement like SELECT field_1, field_2, ( char_field = '1' ), field 4, field5... gives you a boolean expression - is the char_field equal to '1' at the current row? Some versions of Postgres crash when given a boolean expression on the select target list. In that case you can define it as a function CREATE FUNCTION is_one( bpchar ) RETURNS bool AS 'SELECT $1 = ''1''' LANGUAGUE 'sql'; And then do the select as SELECT field_1, field_2, is_one( char_field), field4, field5.... Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера